#!/usr/bin/env python3  /*设定脚本文件直接能执行*/
# -*- coding:utf-8 -*-   /*设置编码*/
"""
@Author: WANDERSON M.PIMENTA
@Software: PyCharm 、Qt Designer and PySide6
@File: tQCopyRightVersionBar.py
@Time: 2024/05/11 16:35
@Function：ctQCopyRightVersionBar：自定义的版权版本工具栏
"""
from tQQtCore import *


# 自定义的版权版本工具栏
class ctQCopyRightVersionBar(QWidget):
    def __init__(self,
                 copyright,
                 version,
                 bg_two,
                 font_family,
                 text_size,
                 text_description_color,
                 radius=8,
                 padding=10):
        super().__init__()
        # <editor-fold desc="设置参数">
        # 设置参数
        self.__m_widget_layout = None
        self.__m_copyright = copyright
        self.__m_version = version
        self.__m_bg_two = bg_two
        self.__m_font_family = font_family
        self.__m_text_size = text_size
        self.__m_text_description_color = text_description_color
        self.__m_radius = radius
        self.__m_padding = padding
        # </editor-fold>

        # 调用布局函数
        self.__f_setUpUIFunc()

    # 布局函数
    def __f_setUpUIFunc(self):
        # 添加中心布局
        self.__m_widget_layout = QHBoxLayout(self)
        self.__m_widget_layout.setContentsMargins(0, 0, 0, 0)

        # 设置样式
        style = f"""
        #bg_frame {{
            border-radius: {self.__m_radius}px;
            background-color: {self.__m_bg_two};
        }}
        .QLabel {{
            font: {self.__m_text_size}pt "{self.__m_font_family}";
            color: {self.__m_text_description_color};
            padding-left: {self.__m_padding}px;
            padding-right: {self.__m_padding}px;
        }}
        """

        # 设置框架
        self.bg_frame = QFrame()
        self.bg_frame.setObjectName("bg_frame")
        self.bg_frame.setStyleSheet(style)

        # 添加布局
        self.__m_widget_layout.addWidget(self.bg_frame)

        # 添加布局
        self.bg_layout = QHBoxLayout(self.bg_frame)
        self.bg_layout.setContentsMargins(0, 0, 0, 0)

        # 添加版权标签
        self.copyright_label = QLabel(self.__m_copyright)
        self.copyright_label.setAlignment(Qt.AlignVCenter)

        # 添加版本标签
        self.version_label = QLabel(self.__m_version)
        self.version_label.setAlignment(Qt.AlignVCenter)

        # 添加弹簧
        self.separator = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)

        # 布局中添加控件
        self.bg_layout.addWidget(self.copyright_label)
        self.bg_layout.addSpacerItem(self.separator)
        self.bg_layout.addWidget(self.version_label)
